package com.hkh.erp.system.core.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hkh.erp.common.api.BasePage;
import com.hkh.erp.common.util.PageConvertUtil;
import com.hkh.erp.system.core.mapper.UserMapper;
import com.hkh.erp.system.api.request.UserPageRequest;
import com.hkh.erp.system.api.response.UserPageResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {


    @Autowired
    private UserMapper userMapper;

    /**
     * 分页查询
     * @param userPageRequest
     * @return
     */
    public BasePage<UserPageResponse> page(UserPageRequest userPageRequest) {
        PageHelper.startPage(userPageRequest.getPageNum(),userPageRequest.getPageSize());
        List<UserPageResponse> list = userMapper.page(userPageRequest);
        PageInfo<UserPageResponse> pageInfo = new PageInfo<>(list);
        return PageConvertUtil.from(pageInfo);
    }
}
